package com.lyy.extend_study.exercise;


/**
 * @Author:  GZQ
 * @date:  2024/11/14 23:23
 */

public class ExtendsExercise02 {
    public static void main(String[] args) {
//        将会输出: 我是A类 hahah 我是B类的有参构造器 我是C类的有参构造器 我是C类的无参构造器
        Third third = new Third();
    }
}

class First {
    public First() {
        System.out.println("我是A类");
    }
}

class Second extends First { // B类, 继承A类
    public Second() {
        System.out.println("我是B类的无参构造器");
    }

    public Second(String name) {
        System.out.println(name + " 我是B类的有参构造器");
    }
}

class Third extends Second { // C类, 继承B类
    public Third() {
        this("hello");
        System.out.println("我是C类的无参构造器");
    }

    public Third(String name) {
        super("hahah");
        System.out.println("我是C类的有参构造器");
    }
}